/*
 * @Author: 高瑞寒 15932717091@163.com
 * @Date: 2022-05-18 22:56:03
 * @LastEditTime: 2022-05-18 23:31:57
 * @LastEditors: 高瑞寒 15932717091@163.com
 * @Description:权限路由
 */
import { publicRoutes, privateRoutes } from '@/router'
export default {
  namespaced: true,
  state: {
    routes: publicRoutes
  },
  mutations: {
    setRoutes(state, newRoutes) {
      state.routes = [...publicRoutes, ...newRoutes]
    }
  },
  actions: {
    filterRouter({ commit }, permission) {
      let router = []
      router = permission.map(item => {
        return privateRoutes.find(route => item === route.name)
      })
      commit('setRoutes', router)
      return router
    }
  }
}
